package forum.repository;

import forum.domain.Token;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2017/4/19.
 */
public interface TokenRepository extends JpaRepository<Token, Integer>, JpaSpecificationExecutor<Token> {


    List<Token> findByTokenname(String username);


    @Transactional
    @Modifying
    @Query(value ="delete from token where token.tokenname = ?1", nativeQuery = true)
    void deleteByTokenname(String tokenname);


}
